<?php

$this->setLayout('template' . DS . 'default.phtml');

$this->startBlock('topbar');
echo $this->navigation->toHtml();
$this->endBlock();

$this->startBlock();
?>
<script language="javascript" type="text/javascript">
    var positions = [];
<?php foreach($this->positions as $position):?>
    positions.push({'templateId':'<?php echo $position->getPageTemplateId()?>', 'code':'<?php echo $position->getCode()?>', 'name':'<?php echo $position->getName()?>'});
<?php endforeach ?>
    $(function(){
        $('#page_template_id').change(function(){
            if($(this).val().length > 0){
                var templateId = $(this).val();
                var html = '<option value="">--</option>';
                for(var i = 0; i < positions.length; i++){
                    if(positions[i].templateId == templateId){
                        html += '<option value="' + positions[i].code + '">' + positions[i].name + '</option>';
                    }
                }
                $('#position').html(html);
            }else{
                $('#position').html('<option value="">--</option>');
            }
        });

        $('#title_enabled').change(titleEnabledChange);
        titleEnabledChange();
    });

    function titleEnabledChange(){
        $('#title_enabled').val() == '1'? $('#field_title').show(): $('#field_title').hide();
    }
</script>
<?php

echo $this->toolbar->toHtml();
echo $this->form->toHtml();
//if($this->ad_parameters){
//    echo $this->loadTemplate($this->ad_parameters['config_path'],
//            array('parameters'=>$this->ad_parameters['parameters']->toArray(),'ad_position'=>$this->ad_position));
//}
//
//if($this->contents_parameters){
//    echo $this->loadTemplate($this->contents_parameters['config_path'],
//            array('parameters'=>$this->contents_parameters['parameters']->toArray()));
//}
//
//if($this->mainsubject_parameters){
//    echo $this->loadTemplate($this->mainsubject_parameters['config_path'],
//            array('parameters'=>$this->mainsubject_parameters['parameters']->toArray()));
//}
$this->endBlock();